package com.queen.testretrofitrxjava.utils;

import com.queen.testretrofitrxjava.entity.Subject;

import java.util.List;

/**
 * Created by liukun on 16/3/19.
 */
public class StringUtil {

    public static String joinSubjectCastNames(List<Subject.Cast> castArray){
        StringBuilder sb = new StringBuilder();
        for (Subject.Cast cast : castArray) {
            sb.append(cast.getName() + "/");
        }

        if (sb.length() > 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString();
    }

    public static String joinSubjectCastNamesWhitSpace(List<Subject.Cast> castArray){
        StringBuilder sb = new StringBuilder();
        for (Subject.Cast cast : castArray) {
            sb.append(cast.getName() + " ");
        }

        return sb.toString().trim();
    }

    public static String joinItem(List<String> stringArray){
        StringBuilder sb = new StringBuilder();

        for (String s : stringArray) {
            sb.append(s + "/");
        }

        if (sb.length() > 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString().trim();
    }
}
